<?php defined('SYSPATH') or die('No direct script access.');

/**
 * Kotan main model containing methods to retrieve data for menus
 * @author bagnz0r
 * @package Kotan
 */

class Model_Kotan extends Model {
	
	/**
	 * Get menu items off database
	 */
	public function get_menu()
	{
		try {
			// Select data from database
			$result = DB::select()
						->from('menu')
						->order_by('weight', 'asc')
						->execute()
						->as_array();
						
			// I18n'ize titles
			for ($i = 0; $i < count($result); $i++)
			{
				$result[$i]['title'] = I18n::get($result[$i]['title']);
			}
		}
		catch (Exception $e)
		{
			return Exception_Handler::handle($e);
		}
		
		return $result;
	}
	
}